//vue3响应式

var obj = {
  _name: "kkai",
  get name() {
    return this._name;
  },

  set name(newValue) {
    console.log("set静态操作符");
    this._name = newValue; //监听不到这个操作 不知道改成功了没有
  },
};

var Pobj = new Proxy(obj, {
  get(target, key, receiver) {
    console.log(`${target[key]}被取到`);
    return target[key];
  },
  set(target, key, newValue, reciver) {
    console.log(`${key}被赋值为${newValue}`);
    // 增益一 Reflect返回boolen值 能够知道是否修改成功
    //增益二 不直接操作对象
    //增益三 reciver再次监听私有属性的改变
    const isFinished = Reflect.set(target, key, newValue, reciver);
    console.log(isFinished);
    target[key] = newValue;
    // value = newValue;
  },
});

Pobj.name = "kaaki";
